package com.yinbw.interview.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mybatisplus.common.model.param.ParamBean;
import com.mybatisplus.common.model.result.ResultBean;
import com.mybatisplus.common.page.PageInfo;
import com.mybatisplus.common.page.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yinbw.interview.entity.Questions;
import com.yinbw.interview.mapper.QuestionsMapper;
import com.yinbw.interview.service.QuestionsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yinbw  http://localhost:8080/swagger-ui/index.html
 * @since 2025-02-13
 */
@Service
public class QuestionsServiceImpl extends ServiceImpl<QuestionsMapper, Questions> implements QuestionsService {

    private final Logger logger = LoggerFactory.getLogger(QuestionsServiceImpl.class);

    @Autowired
    private QuestionsMapper questionsMapper;

    @Override
    public ResultBean<PageVo> pageList(ParamBean<Questions> paramBean){

        PageVo<Questions> pageVo = new PageVo<>();
        PageInfo pageInfo = new PageInfo();
        Page<Questions> page = new Page<>(paramBean.getPageNum(), paramBean.getPageSize());
        questionsMapper.selectPage(page,null);
        pageVo.setDatas(page.getRecords());
        pageInfo.setTotalPageNum(Integer.valueOf(page.getTotal()+""));
        pageVo.setPageInfo(pageInfo);
        return ResultBean.createSuccess(pageVo);
    }
}
